﻿/*
    Autor : Roger Medeiros
    Data  : 01/02/2012
    Site  : www.interacaosistemas.com.br
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using i9PgAdmin.Core;

namespace i9PgAdmin
{
    public partial class DumpExec : Form
    {
        public DumpExec()
        {
            InitializeComponent();
        }

        private Conexao conexao;

        private void imgSair_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            conexao.Servidor = txtservidor.Text;
            conexao.Usuario = txtusuario.Text;
            conexao.Senha = txtsenha.Text;
            conexao.Porta = int.Parse(txtporta.Text);
            conexao.Database = txtdatabase.Text;
            conexao.Comprimir = chkComprimir.Checked;
            if (!txtdestino.Text.EndsWith("\\"))
                txtdestino.Text += "\\";
            conexao.CaminhoDump = txtdestino.Text;
            conexao.CaminhoBin = txtbinpg.Text;
            conexao.Salva();
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void DumpExec_Load(object sender, EventArgs e)
        {
            conexao = new Conexao();
            conexao.Carrega();
            txtservidor.Text = conexao.Servidor;
            txtusuario.Text = conexao.Usuario;
            txtsenha.Text = conexao.Senha;
            txtporta.Text = conexao.Porta.ToString();
            txtdatabase.Text = conexao.Database;
            txtdestino.Text = conexao.CaminhoDump;
            chkComprimir.Checked = conexao.Comprimir;
            txtbinpg.Text = conexao.CaminhoBin;
        }

        private void txtdestino_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                txtdestino.Text = fd.SelectedPath;
        }

        private void txtservidor_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtbinpg_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                txtbinpg.Text = fd.SelectedPath;
        }
    }
}
